#include <iostream>

using namespace std;

class A
{
public:

    A(int *i= NULL):_i(i){
        _i = new int;
        cout<<"A(int *i= NULL)"<<endl;//默认构造函数，没有传参也会被调用
    }
    ~A()
    {
        cout<<"~A()"<<endl;
        if (_i !=NULL)
        {
            delete _i;
        }
    }
    A(const A & another)
    {
        cout<<"A(const A & another)"<<endl;
        _i = new int;
        *_i = *another._i;
    }
    A & operator =(const A & another)
    {
        cout<<"A & operator =(const A & another)"<<endl;
        if(this != &another)
        {
            delete _i;
            _i = new int;
            *_i = *another._i;
        }
    }
    A(A && another)
    {
        cout<<"A(A && another)"<<endl;
        _i = another._i;
        another._i = nullptr;
    }
    A & operator =(A && another)
    {
        cout<<"A & operator =(A && another)"<<endl;
        if(this != &another)
        {
            delete _i;
            _i = another._i;
            another._i = nullptr;
        }
    }

    int *_i;
};
int main()
{
    A a;
    *a._i =10;
    // A b(a);
    // A c;
    // c = a;

    cout<<&a._i<<" "<< a._i<<endl;
    // A d(std::move(a));
    A e;
    e= std::move(a);
    // cout<<&b._i<<endl;
    // cout<<&c._i<<endl;
    // cout<<&d._i<<" "<< d._i<<endl;
    cout<<&e._i<<" "<< e._i<<endl;

    return 0;
}
